<html>
<head>
<script type="text/javascript"
  src="dygraph-combined.js"></script>
<link rel=stylesheet type=text/css href=day8.css>
<title>Node DYgraphs: Graph</title>
</head>
<body>
<?php
if(isset($_POST['nodeselect']))
{
$selected = $_POST['nodes'];
}
else
{
$selected = 1;
}
?>
<form method=POST>
<center><h2>Node Graph</h2></center>
<table>
<tr>
<td><b>Navigation:</b></td>
<td><b><a href=day8.php>Table</a></b></td>
<td><b><a href=graph.php>Graph</a></b></td>
</tr>
</table><br/><br/>
<b>Select Node:</b>
<select name=nodes>
<?php
$con = mysql_connect("127.0.0.1","kkmq12345","updews");
mysql_select_db("dews_training");
$query = mysql_query("SELECT DISTINCT node FROM accel");
if ($query == FALSE)
{
die(mysql_error());
}
while($row = mysql_fetch_array($query))
{
echo "<option value=" . $row['node'] . ">" . $row['node'] . "</option>";
}
mysql_close($con);
?>
</select>
<input type=submit name=nodeselect value=Go /><br/>
<b>Node Selected:</b>
<?php
echo $selected;
?><br/>

<table border=1 align=center><tr><td><div id=graphdiv2 style="width:700px;height:600px"></div></td></tr></table>
<script type="text/javascript">

  g2 = new Dygraph(
    document.getElementById("graphdiv2"),
   "timestamp, xval, yval, zval, mval\n" 
<?php   
   $con = mysql_connect("127.0.0.1","kkmq12345","updews");
   mysql_select_db("dews_training");
   $query = mysql_query("SELECT timestamp, xval, yval, zval, mval FROM accel WHERE node =" . $selected . "");
   while($row = mysql_fetch_array($query))
   {
   echo '+"' . $row['timestamp'] . ',' . $row['xval'] . ',' . $row['yval'] . ',' . $row['zval'] . ',' . $row['mval'] . '\n"';  
}
   ?>
  );
  </script>
  </body>
  </html>